﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CatesList.aspx.cs" Inherits="Manage_Modle_CateGory_CatesList" %>
<%@ Register Src="~/Manage/UserControl/PagingCtrl.ascx" TagName="PagingCtrl" TagPrefix="UserControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta content="MSHTML 6.00.2900.3132" name="GENERATOR" />
	<link href="../../css/mainFrom.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/common.js"></script>
	
	<script language="javascript" type="text/javascript">

var json;
//js ajax
function openurl(url,fun,parameter){

 
    var objxml;
        if(window.ActiveXObject)
        {
            objxml=new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(window.XMLHttpRequest)
        {
            objxml=new XMLHttpRequest();
        }

    objxml.open("POST",url,false);
    objxml.setRequestHeader('Content-type','application/x-www-form-urlencoded;charset=UTF-8;');

        try{
               
                
                objxml.onreadystatechange=function ()
                {
          
                   if(objxml.readyState==4)
                   {
              
                        if (objxml.status=="200")
                        { 
                           
                             retInfo= objxml.responseText;                                             
                             eval(retInfo);
                             eval(fun);
                     
                        }
                    }
                 }
                objxml.send(parameter);
               
        }
        catch(e){
           alert(e);
        } 
     
    }
    
  
      //调用ajax返回json
    
    function getrow(iCategoryID,language,fun)
    {
        openurl('../../GetSubCategory.ashx',fun,'Language='+language+"&iCategoryID="+iCategoryID);
    }

  </script>
	
	
	<script type="text/javascript" language="javascript">
	
	
	
	var parID="";
	        function ExpandSubCategory(iCategoryID,FahterID)
		    {
  
			    var li_father = document.getElementById("li_" + iCategoryID);
			    if (li_father.getElementsByTagName("li").length > 0) //如果已经加载了下级节点则直接展开，不必在去读取数据
			    {
				    ChangeStatus(iCategoryID);
				    return;
			    }
    			
			    li_father.className = "Opened";
			    //打开时显示稍等
			    switchNote(iCategoryID, true);
			    //AJAX回调函数，加载节点
			    getrow(iCategoryID,'<%=Language %>', 'GetSubCategory_callback()');	
			    //Dcms.BLL.Dcms_CateBLL.GetSubCategory(iCategoryID,'<%=Language %>', GetSubCategory_callback);				
		    }
            function ExpandSubCategoryAgain(iCategoryID,FahterID)
		    {

			    var li_father = document.getElementById("li_" + iCategoryID);
			    li_father.className = "Opened";
			    //打开时显示稍等
			    switchNote(iCategoryID, true);
			    //AJAX回调函数，加载节点
			    parID=iCategoryID;
			    getrow(iCategoryID,'<%=Language %>', 'GetSubCategory_callback()');				
		    }
		    function GetSubCategory_callback()
		    {
		    
		      
			    var dt =json;
			    if (dt.Rows.length > 0)
			    {
				    var iCategoryID = dt.Rows[0].Cate_ParentID;
			    }
			    else if(parID!="")
			    {
                      var iCategoryID=parID;
			    }
			    var li_father = document.getElementById("li_" + iCategoryID);
			    var ul_sub = document.getElementById("ulTree_" + iCategoryID); 
			    if(ul_sub != null){
			        li_father.removeChild(ul_sub)
			    }
			    var ul = document.createElement("ul");
			    ul.id = "ulTree_"+ iCategoryID
			    for (var i = 0;i < dt.Rows.length;i++)
			    {
				    if (dt.Rows[i].Cate_IsChild == 1) //如果已没有下一级节点
				    {
					    var li = document.createElement("li");
					    li.className = "Child";
					    li.id = "li_" + dt.Rows[i].Cate_ID;
    					
					    var img = document.createElement("img");
					    img.id = dt.Rows[i].Cate_ID;
					    img.className = "s";
					    img.src = "../../css/s.gif";
    					
					    var a = document.createElement("a");
					    var id = dt.Rows[i].Cate_ID;
					    
    					if(dt.Rows[i].Cate_OpType !="ONLYEDIT"){
				            a.href = "javascript:OpenDocument('" + dt.Rows[i].Cate_ID + "','edit');";
				        }else{
				            a.href = "#";
				        }
					    a.title = dt.Rows[i].Cate_Name;
					    a.innerHTML = dt.Rows[i].Cate_Name.sub(14);
					    
				        var imgEdit = document.createElement("img");
				        imgEdit.id = dt.Rows[i].Cate_ID;
				        imgEdit.className = "s_1";
				        imgEdit.src = "../../images/editfile.gif";
				        imgEdit.onclick = function () {
					        OpenDocument(this.id,"edit");
				        };
				        imgEdit.alt = "编辑";
				        
				        var imgNew = document.createElement("img");
				        imgNew.id = dt.Rows[i].Cate_ID;
				        imgNew.className = "s_1";
				        imgNew.src = "../../images/new.gif";
				        imgNew.onclick = function () {
					        OpenDocument(this.id,"add");
				        };
				        imgNew.alt = "新建子级";
				        imgNew.width = 15;
				        imgNew.height = 15;
				        
				        var imgCopy = document.createElement("img");
				        imgCopy.id = dt.Rows[i].Cate_ID;
				        imgCopy.className = "s_1";
				        imgCopy.src = "../../images/copyfile.gif";
				        imgCopy.onclick = function () {
					        OperateCate(this.id,"copy");
				        };
				        imgCopy.alt = "复制该分类下所有数据到其它分类下";
				        
				        var imgMove = document.createElement("img");
				        imgMove.id = dt.Rows[i].Cate_ID;
				        imgMove.className = "s_1";
				        imgMove.src = "../../images/movefile.gif";
				        imgMove.onclick = function () {
					        OperateCate(this.id,"move");
				        };
				        imgMove.alt = "移动该分类下所有数据到其它分类下";
				    }
				    else    //如果还有下级节点
				    {
					    var li = document.createElement("li");
					    li.className = "Closed";
					    li.id = "li_" + dt.Rows[i].Cate_ID;
    					
					    var img = document.createElement("img");
					    img.id = dt.Rows[i].Cate_ID;
					    img.className = "s";
					    img.src = "../../css/s.gif";
					    img.onclick = function () {
						    ExpandSubCategory(this.id);
					    };
					    img.alt = "展开/折叠";
    					
					    var a = document.createElement("a");
					    a.href = "javascript:ExpandSubCategory(" + dt.Rows[i].Cate_ID + ",'edit');";
					    a.title = dt.Rows[i].Cate_Name;
					    a.innerHTML = dt.Rows[i].Cate_Name.sub(14);
					    
					   
				        var imgEdit = document.createElement("img");
				        imgEdit.id = dt.Rows[i].Cate_ID;
				        imgEdit.className = "s_1";
				        imgEdit.src = "../../images/editfile.gif";
				        imgEdit.onclick = function () {
					        OpenDocument(this.id,"edit");
				        };
				        imgEdit.alt = "编辑";
				        
				        var imgNew = document.createElement("img");
				        imgNew.id = dt.Rows[i].Cate_ID;
				        imgNew.className = "s_1";
				        imgNew.src = "../../images/new.gif";
				        imgNew.onclick = function () {
					        OpenDocument(this.id,"add");
				        };
				        imgNew.alt = "新建子级";
				        imgNew.width = 15;
				        imgNew.height = 15;
				        
				    }
				    li.appendChild(img);
				    li.appendChild(a);
				    if(imgCopy != "undefined" && imgCopy != null)
				    {
				        //li.appendChild(imgCopy);
				        //li.appendChild(imgMove);
				    }
//				    if(dt.Rows[i].Cate_OpType == "EDIT"){
				        li.appendChild(imgEdit);
//				    }
				    if(dt.Rows[i].Cate_OpType !="NONE"){
				        li.appendChild(imgNew);
				    }
				    ul.appendChild(li);	
			    }
			    if(li_father!=null)
			    {
			     li_father.appendChild(ul);
			    }
			    //先显示稍等。。。
			    switchNote(iCategoryID, false);
		    }
    		
		    // 叶子节点的单击响应函数
		    function OpenDocument(iCategoryID,Action)
		    {
			    window.EditMain.location.href = "EditCate.aspx?CatID="+iCategoryID + "&action="+Action;
		    }
		    
		    //移动或复制分类
		    function OperateCate(iCategoryID, Action)
		    {
			    window.EditMain.location.href = "OperateCate.aspx?CatID="+iCategoryID + "&action="+Action;
		    }

		    function ChangeStatus(iCategoryID)
		    {
			    var li_father = document.getElementById("li_" + iCategoryID);
			    if (li_father.className == "Closed")
			    {
				    li_father.className = "Opened";
			    }
			    else
			    {
				    li_father.className = "Closed";
			    }				
		    }

		    function switchNote(iCategoryID, show)
		    {  
			    var li_father = document.getElementById("li_" + iCategoryID);
			    if (show)
			    {
				    var ul = document.createElement("ul");
				    ul.id = "ul_note_" + iCategoryID;
    				
				    var note = document.createElement("li");
				    note.className = "Child";
    				
				    var img = document.createElement("img");
				    img.className = "s";
				    img.src = "../../css/s.gif";
    				
				    var a = document.createElement("a");
				    a.href = "javascript:void(0);";
				    a.innerHTML = "请稍候...";
    				
				    note.appendChild(img);
				    note.appendChild(a);
				    ul.appendChild(note);
				    li_father.appendChild(ul);
			    }
			    else
			    {
				    var ul = document.getElementById("ul_note_" + iCategoryID);
				    if (ul)
				    {
					    li_father.removeChild(ul);
				    }				
			    }
		    }

            function InitTree()
            {
		        // 加载根节点
		        var tree = document.getElementById("CategoryTree");
		        var root = document.createElement("li");
		        root.id = "li_0";
		        tree.appendChild(root);
        		
		        // 加载页面时显示第一级分类
		        ExpandSubCategory(0);
		    }
		    
		    function ValiDate()
		    {
		        try
		        {
		            if(document.getElementById("<%= ddlLanguage.ClientID %>").value == 0)
		            {
		                alert("请选择您要复制到哪个语言版本!");
		                return false;
		            }
		            return confirm("将删除对应语言版本下的分类信息,确定要复制吗?");
		        }
		        catch(ex)
		        {
		            return false;
		        }
		    }

    </script>
</head>
<body  onload="InitTree()">
    <form id="form1" runat="server">
    <div id="incontent">
      <div class="clear"></div>
      <div class="contable">
        <div class="con-ico">
          <div class="con-fl">当前位置：栏目分类管理</div>
          <div class="con-fr">
            <img src="../../images/img-fontid.gif" title="本页技术支持编号" alt="" />010500
          </div>
        </div>
        <div class="clear"></div>
        <div class="hr"></div>
        <div class="imgadnfont">
          <div class="float">
            <img src="../../images/UserloginLog.gif" alt="" />
          </div>
          <div style="line-height: 20px;">
            在这里主要是管理网站上的所有栏目的分类，比如新闻的分类、产品的分类等。通过选择左边类别框中的类别，双击就可以在右边看到类别的信息，可以进行编辑，也可以只接新建一个相似的类别。
            <br />
            <table>
                <tr>
                    <td>
                        <asp:DropDownList ID="ddlLanguage" runat="server"></asp:DropDownList>
                    </td>
                    <td>
                        <asp:Button ID="btnCopy" runat="server" Text="复制分类到另一种语言版本" OnClientClick="return ValiDate();" OnClick="btnCopy_Click" />
                    </td>
                    <td>
                    <a href="#" onclick="window.EditMain.location.href = 'EditCate.aspx?CatID=0&action=add'">新建根级类别</a>
                    </td>
                </tr>
            </table>
          </div>
        </div>
        <div class="clear"></div>
          <div id="leftCate" style="width:250px; float:left">
            <div class="TreeMenu_1" id="CategoryTree">
              
		    </div>    
		    <input type="hidden" id="TextBox1" runat="server" name="节点ID" /><br />
        <input type="hidden" id="TextBox2" runat="server" name="父节点ID" /><br />
          </div>
          <div id="RightCate_1" style="width:480px; float:left">
           <iframe frameborder="0" style="width:480px; height:500px; " src="EditCate.aspx" id="EditMain" name="EditMain"></iframe>
          </div>
        </div>

    </div>

    </form>
</body>
    <script language="javascript" type="text/javascript">
        parent.$("IFRAME_windowTab_SYStem<%= Request.QueryString["ID"]%>").style.height = (document.body.scrollHeight > 560 ? document.body.scrollHeight : 560);
    </script>
</html>